package com.finace.money.presenter;

import com.finace.money.common.util.LogUtil;
import com.finace.money.data.bean.BaseBean;
import com.finace.money.data.bean.EmptyBean;
import com.finace.money.data.bean.ImageBean;
import com.finace.money.net.rto_rxbuild.RxHttpReponseCompat;
import com.finace.money.net.rto_subscriber.ProgressSubcriber;
import com.finace.money.presenter.contract.VerifyCodeContract;
import com.google.gson.JsonObject;

import java.util.stream.Stream;

import javax.inject.Inject;

import io.reactivex.Observable;
import io.reactivex.Scheduler;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import okhttp3.Response;
import okhttp3.ResponseBody;

/**
 * Created by zhangpeng on 2018/1/26.
 */

public class VerifyCodePresenter extends BasePresenter<VerifyCodeContract.IVerifyCodeModel,VerifyCodeContract.View>{

    @Inject
    public VerifyCodePresenter(VerifyCodeContract.IVerifyCodeModel iVerifyCodeModel, VerifyCodeContract.View view) {
        super(iVerifyCodeModel, view);
    }

    public void sendCode(String phone, String type){
        mModel.sendCode(phone,type).compose(RxHttpReponseCompat.<EmptyBean>compatResult())
                .subscribe(new ProgressSubcriber<EmptyBean>(mContext,mView) {
                    @Override
                    public void onNext(EmptyBean emptyBean) {
                        if(hasView()){
                            mView.sendSucceed();
                        }
                    }
                });
    }
    public void getImageCode(){
        mModel.getImageCode().compose(RxHttpReponseCompat.<ImageBean>compatResult())
                .subscribe(new ProgressSubcriber<ImageBean>(mContext,mView) {
                    @Override
                    public void onNext(ImageBean imageBean) {
                        mView.getImageSucess(imageBean);
                    }
                });
    }

}
